#include<bits/stdc++.h>
using namespace std;
long long T,n,ans=-1,a[200005];
bool f[200005];
void dfs(long long step)
{
    if(step==n+1)
    {
        long long sum=0;
        for(long long i=1;i<=n;i++)
        {
            for(long long j=i-1;j>=1;j--)
            {
                if(f[j]==f[i])
                {
                    if(a[j]==a[i])
                    {
                        sum+=a[j];
                    }
                    break;
                }
            }
        }
        ans=max(ans,sum);
        return;
    }
    f[step]=1;
    dfs(step+1);
    f[step]=0;
    dfs(step+1);
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    while(T--)
    {
        memset(f,0,sizeof(f));
        ans=-1;
        cin>>n;
        for(long long i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        dfs(1);
        cout<<ans<<endl;
    }
    return 0;
}
